﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QBS.Tools
{
    public class MyDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public int TryInt(TKey key, int def = 0)
        {
            if (this.Keys.Contains(key))
                return this[key].ToInt();
            return def;
        }
        public string TryStr(TKey key, string def = "")
        {
            if (this.Keys.Contains(key))
                return this[key].ToString();
            return def;
        }
        public decimal TryDec(TKey key, int def = 0)
        {
            if (this.Keys.Contains(key))
                return this[key].ToDecimal();
            return def;
        }
    }
}